package com.erp.myAdapter

import android.annotation.SuppressLint
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_duoxuan_item.view.*

/**
 * Created by Administrator on 2017/11/17/017.
 * 作者：刘洋
 */
class ScJieHaoXuanKAdapter(private var jiehaolist : MutableList<String>, val context :Context) : BaseAdapter(){
    var minflater: LayoutInflater = LayoutInflater.from(context)
    var list :MutableList<String> = ArrayList()
    @SuppressLint("ViewHolder")
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v=minflater.inflate(R.layout.lv_duoxuan_item,null)
        Myutil.settv(jiehaolist[position],v.TvName)
        v.CbXuan.isChecked = list.contains(jiehaolist[position])
        return v
    }
    fun dowenitem(position: Int){
        if(list.contains(jiehaolist[position])){
            list.remove(jiehaolist[position])
        }else{
            list.add(jiehaolist[position])
        }
    }
    override fun getItem(position: Int): Any = jiehaolist[position]

    override fun getItemId(position: Int): Long = position.toLong()

    override fun getCount(): Int = jiehaolist.size
}